﻿
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="path" value="${pageContext.request.contextPath}" />
<!DOCTYPE HTML>
<html>
<jsp:include page="../../common/head.jsp"></jsp:include>
<body>
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>
		Student管理 <span class="c-gray en">&gt;</span> 信息列表 <a
			class="btn btn-success radius r"
			style="line-height: 1.6em; margin-top: 3px"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<div class="page-container">
		<form action="${path}/student/listPage.json" id="frm_list">
			<input type="hidden" name="pageNum" value="1" />
			<input type="hidden" name="pageSize" value="5" />
			<div class="text-c">
				<input type="text" class="input-text" style="width: 250px"
					placeholder="请输入学生姓名..." id="" name="name">
				<button type="button" class="btn btn-success radius" id="search" name="">
					<i class="Hui-iconfont">&#xe665;</i> 搜索
				</button>
			</div>
		</form>
		<div class="cl pd-5 bg-1 bk-gray mt-20">
			<span class="l"><a href="javascript:;" onclick="datadel()"
				class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i>
					批量删除</a> </span> <span class="r">共有数据：<strong id="total"></strong> 条
			</span>
		</div>
		<div class="mt-20">
			<table
				class="table table-border table-bordered table-hover table-bg table-sort">
				<thead>
					<tr class="text-c">
						<th width="25"><input type="checkbox" name="" value=""></th>
						<th width="25">序号</th>
								<th width="100">学号</th>
								<th width="100">姓名</th>
								<th width="100">性别</th>
								<th width="100">专业</th>
								<th width="100">出生日期</th>
								<th width="100">总学分</th>
								<th width="100">备注</th>
								<th width="100">照片</th>
						<th width="100">操作</th>
					</tr>
				</thead>
				<tbody id="tbody_list">
					
				</tbody>
			</table>
		</div>
		<div class="mt-10" id="page"></div>
	</div>
		<!-- 第一步：编写模版。你可以使用一个script标签存放模板，如： -->
		<script id="demo" type="text/html">
			{{# for(var i = 0, len = d.data.list.length; i < len; i++){ }}
				{{# var l = d.data.list[i]}}
				<tr class="text-c">
							<td><input type="checkbox" value="{{ l.id}}" name="ids"></td>
					<td>{{i+1}}</td>
							<td>{{l.orderNo}}</td>
							<td>{{l.name}}</td>
							<td>{{l.sex=='01'?'男':'女' }}</td>
							<td>{{l.major=='01'?'计算机':'软件工程'}}</td>
							<td>{{l.birthday}}</td>
							<td>{{l.totalCredit}}</td>
							<td>{{l.remark}}</td>
							<td>{{l.imgPath}}</td>
					<td class="td-manage"><a title="查看" href="javascript:;"
							onclick="student_show('查看学生信息','${path}/student/goShow?studentId={{l.id}}','400','500')" class="ml-5"
							style="text-decoration: none"><i class="Hui-iconfont">&#xe62c;</i></a>
							<a title="编辑" href="javascript:;"
							onclick="student_edit('修改学生信息','${path}/student/goUpdate?studentId={{l.id}}')" class="ml-5"
							style="text-decoration: none"><i class="Hui-iconfont">&#xe6df;</i></a>
							<a title="删除" href="javascript:;" onclick="student_del(this,'{{l.id}}')"
							class="ml-5" style="text-decoration: none"><i
								class="Hui-iconfont">&#xe6e2;</i></a>
					</td>
				</tr>
			{{# } }}
		</script>
	<jsp:include page="../../common/foot.jsp"></jsp:include>
	<script type="text/javascript" src="${path}/lib/laypage/laypage.js"></script> 
	<script type="text/javascript" src="${path}/lib/laytpl/laytpl.js"></script> 
	<script type="text/javascript">
		$(function() {
			initPage("frm_list","demo","tbody_list", "page");
			$('#search').click(function(){
				initPage("frm_list","demo","tbody_list", "page");
			});
		});
		
		function datadel(){
			if($('input[name="ids"]:checked').length == 0){
				layer.msg('请选择至少一条数据进行删除', {
					  icon: 2,
					  skin: 'layer-ext-moon'
				});
			}else{
				layer.confirm('确认要批量删除吗？', function(index) {
					var ids=[];
					$('input[name="ids"]:checked').each(function(){
						ids.push($(this).val());
					});
					$.post('${path}/student/del',{ids:ids.join(',')},function(result){
						if(checkCode(result)){
							layer.msg('批量删除成功', {
								  icon: 1,
								  skin: 'layer-ext-moon'
							});
							initPage("frm_list","demo","tbody_list", "page");
						}
					},'json').error(function(){
						serverError();
					});
				});
			}
		} 
		
		function reload(){
			reloadPage("frm_list","demo","tbody_list", "page");
		}
		
		/*用户-查看*/
		function student_show(title, url, w, h) {
			layer_show(title, url, w, h);
		}

		/*用户-编辑*/
		function student_edit(title, url, w, h) {
			layer_show(title, url, w, h);
		}

		/*用户-删除*/
		function student_del(obj, id) {
			layer.confirm('确认要删除吗？', function(index) {
				$.post('${path}/student/del',{ids:id},function(result){
					if(checkCode(result)){
						layer.msg('删除成功', {
							  icon: 1,
							  skin: 'layer-ext-moon'
						});
						initPage("frm_list","demo","tbody_list", "page");
					}
				},'json').error(function(){
					serverError();
				});
			});
		}
	</script>
</body>
</html>